package com.chance.cc.crawler.development.command.schedule.du;

import com.alibaba.fastjson.JSON;
import com.chance.cc.crawler.development.command.meta.keyword.CrawlerDomainKeywordCommand;
import com.chance.cc.crawler.meta.core.bean.crawler.CrawlerDomainKeys;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.apache.commons.io.IOUtils;

import java.io.FileInputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.List;

/**
 * @author bx
 * @date 2020/12/15 0015 13:26
 */
@Data
@AllArgsConstructor
public class DUKeywordList {

    private String keyword;

    private String category;

//    private String businessTag;

    public static void main(String[] args) throws IOException {
        List<String> kwLines = IOUtils.readLines(new FileInputStream("D:\\chance\\gitspace\\chance-crawler-development\\crawler-scripts-command\\src\\main\\java\\com\\chance\\cc\\crawler\\development\\command\\schedule\\du\\du_kw.txt"), Charset.forName("UTF-8"));

        for (String kwLine : kwLines) {
            if (kwLine.startsWith("#")){
                continue;
            }
            String[] dyKeyword = kwLine.split("\t");

            CrawlerDomainKeywordCommand crawlerDomainKeywordCommand =
                    new CrawlerDomainKeywordCommand("192.168.1.215",9599);

            CrawlerDomainKeys crawlerDomainKeys = new CrawlerDomainKeys();
            crawlerDomainKeys.setDomain("du_app");
            crawlerDomainKeys.setKeyword(dyKeyword[0]);
            crawlerDomainKeys.setSite(dyKeyword[1]);
            crawlerDomainKeys.setStatus(0);
            crawlerDomainKeywordCommand.addOrUpdateKeys(crawlerDomainKeys);
            System.out.println(JSON.toJSONString(dyKeyword));
        }


    }
}
